Skip to content

Improve how thread priority is applied#162

Open
TrentHouliston wants to merge 3 commits into
mainfrom
houliston/priority-changes
Open

Improve how thread priority is applied#162
TrentHouliston wants to merge 3 commits into
mainfrom
houliston/priority-changes

Conversation

@TrentHouliston

@TrentHouliston TrentHouliston commented Dec 23, 2024

Copy link
Copy Markdown
Member

Summary

Restore typed task priorities via the PriorityLevel smart enum (7 DSL levels) and ThreadPriority RAII for OS thread priority during task execution.

Rebased onto main now that the lock-free scheduler is merged (#193). The branch history was squashed to two commits on top of main (priority integration + Windows/macOS fixes).

  • Bucket mapping: Seven DSL levels map to five scheduler buckets — REALTIME → REALTIME; HIGHEST/HIGH → HIGH; NORMAL → NORMAL; LOWEST/LOW → LOW; IDLE/UNKNOWN → IDLE
  • Preserved from PR Improve how thread priority is applied #162: src/PriorityLevel.hpp, ThreadPriority RAII, DSL fusion, CI cap_sys_nice, PriorityLevel/ThreadPriority tests
  • Scheduler integration: queue/Priority.hpp bucket helpers, ReactionTask/Group/Pool/Scheduler typed priority paths, Group/Scheduler tests
  • Pool workers: worker threads use ThreadPriority(HIGHEST) while dequeuing (FIFO responsiveness on Linux); task callbacks set OS priority via ThreadPriority RAII in CallbackGenerator

The exploratory houliston/priority-enum branch can be deleted; all work lives here.

Test plan

@TrentHouliston TrentHouliston changed the base branch from cmurtagh/priority_fixes to main December 23, 2024 10:38
CMurtagh-LGTM
CMurtagh-LGTM previously approved these changes Jan 1, 2025

@CMurtagh-LGTM CMurtagh-LGTM left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good To Me

Comment thread src/PriorityLevel.hpp
Comment thread src/dsl/word/Always.hpp
CMurtagh-LGTM
CMurtagh-LGTM previously approved these changes Jan 2, 2025
CMurtagh-LGTM
CMurtagh-LGTM previously approved these changes Jan 30, 2025
Comment thread src/util/ThreadPriority.cpp Outdated
@WongAaronSW

Copy link
Copy Markdown
Contributor

It is important to note that when testing some of these UnitTests will require elevated permissions:
When running on a Linux Environment, a user must setup their binary's capabilities.

sudo setcap 'cap_sys_nice=eip' ./tests/util/ThreadPriority

TrentHouliston and others added 2 commits June 17, 2026 12:51
Rebased onto main after lock-free scheduler merge (#193).

Introduce typed PriorityLevel, ThreadPriority RAII for set/restore,
and integrate priority handling with the lock-free scheduler pools.

Co-authored-by: Cursor <cursoragent@cursor.com>
Qualify PriorityLevel enum cases for MSVC, scope pool HIGHEST elevation to
dequeue only so ChronoController is not starved, and drop REALTIME-only
calibration that ran on the wrong thread during reactor construction.

Co-authored-by: Cursor <cursoragent@cursor.com>
@TrentHouliston TrentHouliston force-pushed the houliston/priority-changes branch from 9516ae2 to 2370255 Compare June 17, 2026 02:52
Qualify PriorityLevel cases for Windows and switch on priority() for
portability; limit HIGHEST thread priority to dequeue so ChronoController
is not starved on macOS.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thread pinning/scheduling

4 participants